package com.sfac.springBoot.module.test.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sfac.springBoot.module.common.entity.AbstractEntity;

import javax.persistence.*;
import java.util.List;

/**
 * personal demo
 **/
@Entity
@Table(name = "test_clazz")
public class Clazz extends AbstractEntity {
    private String clazzName;

    @ManyToOne(targetEntity = School.class,cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name="school_id",unique = true)
    @JsonIgnore
    private School school;

    public String getClazzName() {
        return clazzName;
    }

    public void setClazzName(String clazzName) {
        this.clazzName = clazzName;
    }

    public School getSchool() {
        return school;
    }

    public void setSchool(School school) {
        this.school = school;
    }

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
    }

    @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinTable(name = "test_clazz_student",joinColumns =@JoinColumn(name = "clazz_id"),
            inverseJoinColumns = @JoinColumn(name = "student_id"))
    private List<Student> students;
}















